package com.hippo.core.Enum.sys;

import com.hippo.core.Enum.SuperEnum;
import lombok.Data;
import lombok.Getter;

import java.util.Iterator;

/**
 * @ClassName SexEnum
 * @Description TODO 性别枚举
 * @Author tangxl
 * @create 2023-04-26 08:38
 **/

@Getter
public enum SexEnum implements SuperEnum {
    MAN(1,"男"),
    WOMAN(2,"女"),
    ON_OTHER(3,"");

    private Integer code;
    private String name;

    SexEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCodeByName(String name){
        for (SexEnum sexEnum : SexEnum.values()) {
            if (sexEnum.getName().equals(name)){
                return sexEnum.getCode();
            }
        }
        return 0;
    }

    public String getNameByCode(Integer code){
        for(SexEnum sexEnum:SexEnum.values()){
            if(sexEnum.getCode().equals(code)){
                return sexEnum.getName();
            }
        }
        return "";
    }
}
